simple implementation of unwrapping dataspecs from specs created usin… #226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @ikitommi , I found a nice ticket open (#111 ) and I wanted to give it a shot. This is a simplified implementation of unwrapping specs created from data-specs. I used multimethods to dispatch to common spec operators, but the current solution is not exhaustive therefore might have some possibilities not covered, need to check this out.
Some drawbacks.
clj
basically because I can't get the function out of symbols incljs
(this situation again). I run the test in cljs and got the following error message for the simpler specs I wrote:As seems like cljs compile the
boolean?
function to a js object and I get aSymbol
back fromresolve
macro in cljs.As we can see the
::age
keyword was transformed to a full form asclojure.core/post-int?
therefore when I use(ds/unspec (ds/spec {:name ::test :spec ::age})) ;;=> #function[clojure.core/pos-int?]
It works, but is not the same as recovering the full qualified keyword that defined the pos-int? in the first place.
TODO: I would like to present this rationale for the solution to see if is viable in the long run, as well as discuss the
unspec
arity [I don't see why not only receive the spec itself, idk what kind of parameters would be nice to have as well]. After, I need to implement,ds/opt
andds/req
over map keys.Thanks!